package com.qst.like.controller;

import com.qst.domain.entity.Mess;
import com.qst.like.service.LikelistService;
import com.qst.like.service.MusicService;
import com.qst.like.service.MylikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController
@RequestMapping("/mylike")
public class LikeController {

    @Autowired
    MusicService musicService;

    @Autowired
    LikelistService likelistService;

    @Autowired
    MylikeService mylikeService;

    @GetMapping("/getMyLike")
    public Mess getMylike(@RequestHeader("id")Integer id){
        return Mess.success().data("likeList",musicService.getLikeMusic(id));
    }

    @GetMapping("/getLikeList")
    public Mess getLikeList(@RequestHeader("id")Integer id){
        return likelistService.getList(id);
    }

    @PostMapping("/add")
    public Mess addLike(@RequestHeader("id")Integer id,Integer musicId){
        return mylikeService.addLike(musicId,id);
    }
    @PostMapping("/remove")
    public Mess remove(@RequestHeader("id")Integer id,Integer musicId){
        return mylikeService.removeLike(musicId,id);
    }

    @PostMapping("/addList")
    public Mess addList(@RequestHeader("id")Integer id,@RequestParam(value = "listId") Integer listId){
        return likelistService.addList(listId,id);
    }

    @PostMapping("/removeList")
    public Mess removeList(@RequestHeader("id")Integer id,Integer listId){
        return likelistService.removeList(listId,id);
    }
}
